package com.example.shop_2305

import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.alibaba.android.arouter.facade.Postcard
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.facade.callback.NavigationCallback
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.ToastUtils
import com.example.user.LoginActivity

/**
 * library不可单独运行  app可单独运行
 */
@Route(path = "/app/MainActivity")
class MainActivity : AppCompatActivity() {
    @SuppressLint("MissingInflatedId")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }

        findViewById<TextView>(R.id.tv).setOnClickListener {
            //startActivity(Intent(this,LoginActivity::class.java))
            /**
             * 当登录了 跳转到主页  未登录跳转到登录界面
             */
            ARouter.getInstance().build("/user/UserInfoActivity").navigation()
              /*  .navigation(this,object:NavigationCallback{
                override fun onFound(postcard: Postcard?) {
                    //找到
                }

                override fun onLost(postcard: Postcard?) {
                    //丢失 迷路
                    ToastUtils.showLong("路径写错了")
                }

                override fun onArrival(postcard: Postcard?) {
                    //到达
                }

                override fun onInterrupt(postcard: Postcard?) {
                    //拦截
                }
            })*/

        }
    }
}